/**
 * Created by 83617 on 2019/1/11.
 */
//Models...
var Index = require('../app/controllers/index')
var User = require('../app/controllers/user')
var Society = require('../app/controllers/society')
var Activity = require('../app/controllers/activity')

var _ = require('underscore')

module.exports = function(app){
    //pre handle user
    app.use(function(req,res,next){
        var _user = req.session.user

        app.locals.user = _user

        next()
    })

    //Index
    app.get('/',User.admin,Index.index)

    app.get('/index/page/switch',User.admin,Index.pageSwitch)

    //User
    app.get('/adminLogin',User.toLoginPage)

    app.post('/admin/register',User.register)

    app.post('/admin/login',User.login)

    app.get('/admin/logout',User.logout)

    //Society
    app.get('/society/detail',User.admin,Society.societyDetails)

    app.get('/admin/society',User.admin,Society.toSocietyInsertPage)

    app.get('/admin/update/society/:id',User.admin,Society.updateSociety)

    app.post('/admin/society/new',User.admin,Society.saveIcon,Society.updateSocietyFunc)

    app.delete('/admin/delete/society',User.admin,Society.deleteSociety)

    //Activity
    app.get('/list/activity',User.admin,Activity.listActivity)

    app.get('/admin/activity',User.admin,Activity.toActivityInsertPage)

    app.post('/admin/activity/new',User.admin,Activity.updateActivityFunc)
}
